package com.itheima_01;

import java.util.Scanner;

public class StringDemo3_2 {
    public static void main(String[] args) {
        String username = "12345";
        String password = "123";
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入用户名：");
            String name = sc.nextLine();
            System.out.println("请输入密码：");
            String word = sc.nextLine();
            //字符串内容比较
            if (name.equals(username) && word.equals(password)) {
                System.out.println("登录成功！");
                break;
            } else {
                if (i < 2) {
                    System.out.println("登录失败，用户名或密码不正确，您还有" + (2-i) + "次机会，请重新登录");
                } else {
                    System.out.println("登录失败，您的账户已被锁定，请与管理人员联系。");
                }
            }
        }
    }
}
